package com.zby.test.util.factory;

import com.zby.test.query.SqlQuery;
import com.zby.test.util.common.CommonUtil;
import com.zby.test.util.exception.GenericException;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * Created By zby on 21:20 2019/1/23
 * 创建与数据库的会话
 */

public class Session<T> {

    /**
     * 与数据库的连接对象
     */
    private Connection connection;

    public Session(Connection connection) {
        this.connection = connection;
    }

    /**
     * Created By zby on 23:04 2019/1/23
     * 创建sql查询语句
     */
    public SqlQuery createSqlQuery(String sql) {
        if (CommonUtil.isNull(sql)) {
            throw new GenericException("sql不能为空");
        }
        return new SqlQuery(connection,sql);
    }

}
